//
//  DHeaderCollectionCell.m
//  Car
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 岳明. All rights reserved.
//

#import "DHeaderCollectionCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface DHeaderCollectionCell ()

@property (nonatomic, strong) UIImageView *imageView;

@end

@implementation DHeaderCollectionCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageView];
    }
    return self;
}

- (void)setDiscuss:(YZLDiscuss *)discuss {
    if (_discuss != discuss) {
        _discuss = discuss;
    }
    dispatch_queue_t global = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_async(global, ^{
        NSURL *url =  [NSURL URLWithString: _discuss.focusImage];
        dispatch_async(dispatch_get_main_queue(), ^{
            [self.imageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"D0"]];
        });
    });
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.imageView.frame = self.contentView.bounds;
}



@end
